#include "SMPPBind.hpp"

using namespace smpp::pdu;

Bind::Bind(
const Header &nHeader,
const CoctetString &nSystemId,
const CoctetString &nPassword,
const CoctetString &nSystemType,
const quint8 nInterfaceVersion,
const quint8 nAddrTON,
const quint8 nAddrNPI,
const CoctetString &nAddressRange):
Header(nHeader),
_SystemId(nSystemId),
_Password(nPassword),
_SystemType(nSystemType),
_InterfaceVersion(nInterfaceVersion),
_AddrTON(nAddrTON),
_AddrNPI(nAddrNPI),
_AddressRange(nAddressRange){}

Bind::Bind(const Bind &nBind):
Header(nBind),
_SystemId(nBind.getSystemId()),
_Password(nBind.getPassword()),
_SystemType(nBind.getSystemType()),
_InterfaceVersion(nBind.getInterfaceVersion()),
_AddrTON(nBind.getAddrTON()),
_AddrNPI(nBind.getAddrNPI()),
_AddressRange(nBind.getAddressRange()){}

bool Bind::operator ==(const Bind &nBind) const{
	return (_SystemId == nBind.getSystemId() &&
			_Password == nBind.getPassword() &&
			_SystemType == nBind.getSystemType() &&
			_InterfaceVersion == nBind.getInterfaceVersion() &&
			_AddrTON == nBind.getAddrTON() &&
			_AddrNPI == nBind.getAddrNPI() &&
			_AddressRange == nBind.getAddressRange());
}

bool Bind::operator !=(const Bind &nBind) const{
	return !this->operator==(nBind);
}

Bind &Bind::operator =(const Bind &nBind){
	if(*this == nBind)
		return *this;
	_SystemId = nBind.getSystemId();
	_Password = nBind.getPassword();
	_SystemType = nBind.getSystemType();
	_InterfaceVersion = nBind.getInterfaceVersion();
	_AddrTON = nBind.getAddrTON();
	_AddrNPI = nBind.getAddrNPI();
	_AddressRange = nBind.getAddressRange();
	return *this;
}


void Bind::setSystemId(const CoctetString &sSystemId){
	_SystemId = sSystemId;
}

const CoctetString &Bind::getSystemId() const{
	return _SystemId;
}

void Bind::setPassword(const CoctetString &sPassword){
	_Password = sPassword;
}

const CoctetString &Bind::getPassword() const{
	return _Password;
}

void Bind::setSystemType(const CoctetString &sSystemType){
	_SystemType = sSystemType;
}

const CoctetString &Bind::getSystemType() const{
	return _SystemType;
}

void Bind::setInterfaceVersion(const quint8 nInterfaceVersion){
	_InterfaceVersion = nInterfaceVersion;
}

const quint8 Bind::getInterfaceVersion() const{
	return _InterfaceVersion;
}

void Bind::setAddrTON(const quint8 nAddrTON){
	_AddrTON = nAddrTON;
}

const quint8 Bind::getAddrTON() const{
	return _AddrTON;
}


void Bind::setAddrNPI(const quint8 nAddrNPI){
	_AddrNPI = nAddrNPI;
}

const quint8 Bind::getAddrNPI() const{
	return _AddrNPI;
}

void Bind::setAddressRange(const CoctetString &sAddressRange){
	_AddressRange = sAddressRange;
}

const CoctetString &Bind::getAddressRange() const{
	return _AddressRange;
}

void Bind::calcCommandLength(){
	_CommandLength = 23 + _SystemId.size() + _Password.size() + 
		_SystemType.size() + _AddressRange.size();
}
